﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrderDetail.aspx.cs" Inherits="Cxx.OrderManagerSys.OrderDetail" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <link href="UI/dui.min.css" rel="stylesheet" />
    <link href="UI/ui_k.css" rel="stylesheet" />
    <link rel="stylesheet" href="layui/css/layui.css" />
    <title>订单详情</title>
    <style>
        button.disabled {
            background: #ccc;
        }
    </style>

    <script>
        window.console = window.console || function (t) { };
    </script>
    <script>
        if (document.location.search.match(/type=embed/gi)) {
            window.parent.postMessage("resize", "*");
        }
    </script>
</head>
<body translate="no">
    <div class="p10">
        <form id="form1" runat="server" class="layui-form">
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <div>
                    <table class="d-grid d-gridtable3" style="width: 100%;">
                        <tbody>
                            <tr>
                                <td class="d-t-head" style="width: 15%;">单号:
                                </td>
                                <td style="width: 15%;">
                                    <asp:TextBox ID="txtOrderCode" MaxLength="16" CssClass="layui-input" runat="server"></asp:TextBox>
                                </td>
                                <td class="d-t-head" style="width: 15%;">日期:
                                </td>
                                <td style="width: 55%;">
                                    <asp:TextBox ID="txtDateTime" CssClass="layui-input" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="d-t-head" style="width: 25%;">有无单子:
                                </td>
                                <td>
                                    <input type="checkbox" runat="server" id="ckHasOrder" name="close" lay-skin="switch" lay-text="有|无" />
                                </td>
                                <td class="d-t-head" style="width: 25%;">是否已结:
                                </td>
                                <td>
                                    <input type="checkbox" runat="server" id="ckPaymented" name="close" lay-skin="switch" lay-text="是|否" />
                                </td>
                            </tr>
                            <tr>
                                <td class="d-t-head">收货单位:
                                </td>
                                <td>
                                    <asp:TextBox ID="txtCustomer" MaxLength="16" CssClass="layui-input" runat="server"></asp:TextBox>
                                </td>
                                
                                <td class="d-t-head">总金额:
                                </td>
                                <td>
                                    <asp:TextBox ID="txtTotalAmount" placeholder="不填时自动计算" onkeyup="value = $.trim(value).replace(/[^\d]/g, '')" MaxLength="8" CssClass="layui-input" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div>
                        <div>
                            <div class="main">
                                <input data-list='' id="getData" style="display: none" runat="server" />
                            </div>
                        </div>
                        <div>
                            <div>
                                <br />
                                <button type="button" class="layui-btn" id="addBtn">
                                    <i class="layui-icon">&#xe608;</i> 添加
                                </button>
                                <div class="addMain">
                                </div>
                                <input value="" id="getData" style="display: none" />
                            </div>
                        </div>
                    </div>
                    <table class="d-grid d-gridtable3 mt10" style="width: 100%;">
                        <tbody>
                            <tr>
                                <td class="d-t-head" style="width: 15%;">备注:
                                </td>
                                <td colspan="3">
                                    <asp:TextBox ID="txtAttention" Height="100px" TextMode="MultiLine" CssClass="layui-textarea" runat="server" Width="100%"></asp:TextBox>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>

            </div>
            <div class="btn-oper clearfix">
                <div class="mt10" align="center">
                    <%--<asp:Button ID="btSaveAndCopy" CssClass="layui-btn layui-btn-radius layui-btn-sm" runat="server" Text="保存并复制" OnClick="SaveAndCopy_Click" />--%>
                    <asp:Button ID="btSave" CssClass="layui-btn layui-btn-radius layui-btn-sm" runat="server" Text="保存" OnClick="Save_Click" />
                    <asp:Button ID="btModify" CssClass="layui-btn layui-btn-sm layui-btn-radius layui-btn-danger" runat="server" Text="修改" OnClick="btModify_Click" />
                </div>

            </div>
            <script src="JS/jquery-1-7-2.js"></script>
            <script src="JS/jq_addDiv.js?v=201801201"></script>
            
            <script src="laydate/laydate.js"></script>
            <script src="layui/layui.all.js"></script>
            <script>
                //$(function () {
                //    $('[data-toggle="tooltip"]').tooltip();
                //    $("#tabs1").DTabs({ autoFade: false });
                //});

                function SaveOrder() {
                    $('#btSave').click();
                }
            </script>
            <script type="text/javascript">
                var html = '<table class="mt10 mb10 d-grid d-gridtable3 J_addDiv" style="width: 100%;">' +
                    '<tbody>' +
                    '<tr>' +
                    '<td class="d-t-head">名称:' +
                    '</td>' +
                    '<td>' +
                    '<input type="text" class="layui-input J_input1 w100">' +
                    '</td>' +
                    '<td class="d-t-head">倍数:' +
                    '</td>' +
                    '<td>' +
                    '<input type="text" onkeyup="value = $.trim(value).replace(/[^\\d]/g, \'\')" class="layui-input J_input5 w100">' +
                    '</td>' +
                    '<td class="d-t-head">数量:' +
                    '</td>' +
                    '<td>' +
                    '<input type="text" onkeyup="value = $.trim(value).replace(/[^\\d]/g, \'\')" class="layui-input J_input2 w100">' +
                    '</td>' +
                    '<td class="d-t-head">单价:' +
                    '</td>' +
                    '<td>' +
                    '<input type="text" class="layui-input J_input3 w100">' +
                    '</td>' +
                    '<td class="d-t-head">金额:' +
                    '</td>' +
                    '<td>' +
                    '<input type="text" placeholder="不填时自动计算" class="layui-input J_input4 w100">' +
                    '</td>' +
                    '<td>' +
                    '<button class="J_closeBtn layui-btn layui-btn-primary layui-btn-sm">' +
                    '<i class="layui-icon">&#xe640;</i>' +
                    '</button>' +
                    '</td>' +
                    '</tr>' +
                    '<tr>' +
                    '</tbody >' +
                    '</table >';

                var initList = '<%=DetailJson %>';
                var add = $("#addBtn").addBtn({
                    html: html,
                    addMain: ".addMain",
                    addDiv: ".J_addDiv",
                    closeBtn: '.J_closeBtn',
                    initData: initList
                });

                laydate.render({
                    elem: '#txtDateTime',
                    type:'datetime',
                    format: 'yyyy-MM-dd HH:mm:ss'//指定元素
                });

                $(function () {
                    $("form[id='form1'] input:text").keypress(function (e) {
                        if (e.which == 13) {// 判断所按是否回车键  
                            var inputs = $("form[id='form1']").find(":text"); // 获取表单中的所有输入框  
                            var idx = inputs.index(this); // 获取当前焦点输入框所处的位置  
                            if (idx == inputs.length - 1) {// 判断是否是最后一个输入框 
                                alert('到最后啦');
                                //if (confirm("最后一个输入框已经输入,是否提交?")) // 用户确认  
                                //    $("form[name='contractForm']").submit(); // 提交表单  
                            } else {
                                inputs[idx + 1].focus(); // 设置焦点  
                                inputs[idx + 1].select(); // 选中文字  
                            }
                            return false;// 取消默认的提交行为  
                        }
                    });
                }); 

                function MakeSave() {
                    $.ajax({
                        url: "SaveDetailList",
                        data: $("#getData").val(),
                        type: "post",
                        success: function (data) {
                            var jsonResult = JSON.parse(data);
                            if (jsonResult.Status != 1) {
                                alert(jsonResult.Message);
                            } else {
                                alert("保存成功");
                            }
                        }
                    });
                }
            </script>
        </form>
    </div>

</body>
</html>
